//
//  RootNavigationViewController.swift
//  V2ex-Swift
//
//  Created by Jasper on 2/28/16.
//  Copyright © 2016 Fin. All rights reserved.
//

import UIKit
import SwiftHEXColors

class RootNavigationViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let color: UIColor = UIColor(hex: 0x373737)!
        navigationBar.setBackgroundImage(createImageWithColor(color), for: .default)
        navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white]
        navigationBar.isTranslucent = false
        
//        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "高楼指数", style: .Plain, target: self, action: #selector(leftClicked(_:)))
    }

//    func leftClicked(sender: UIBarButtonItem) {
//    
//    }

    func createImageWithColor(_ color:UIColor) -> UIImage{
        return createImageWithColor(color, size: CGSize(width: 1, height: 1))
    }
    
    func createImageWithColor(_ color:UIColor,size:CGSize) -> UIImage {
        let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
        UIGraphicsBeginImageContext(rect.size);
        let context = UIGraphicsGetCurrentContext();
        context?.setFillColor(color.cgColor);
        context?.fill(rect);
        
        let theImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return theImage!;
    }
}




